package socket;

public class PriorityDemo {
    public static void main(String[] args) {
        Thread min = new Thread(){
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println("min");
                }
            }
        };
        min.setPriority(Thread.MIN_PRIORITY);
        Thread max= new Thread(){
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println("max");
                }
            }
        };
        max.setPriority(Thread.MAX_PRIORITY);
        Thread norm = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println("norm");
                }
            }
        };
        /*
        线程提供了三个常量：
        final static int MIN_PRIORITY =1; 表示线程可以允许的最小优先级
        final static int MIN_PRIORITY =1; 表示线程创建时默认优先级
        final static int MIN_PRIORITY =1; 表示线程可以允许的最大优先级
         */
        min.setPriority(Thread.MIN_PRIORITY);
        max.setPriority(Thread.MAX_PRIORITY);
        norm.setPriority(Thread.NORM_PRIORITY);
        min.start();
        max.start();
        norm.start();
    }
}
